import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;

/**
 * @author yuanbinbing
 */
public class Task05_05 {
    public static void main(String[] args) {
        Random random = new Random();
        //泛型,<>中放的是集合中元素的类型
        ArrayList<Integer> arrayList = new ArrayList<Integer> ();
        while (arrayList.size() < 10) {
            int num = random.nextInt(40) + 1;
            if (!arrayList.contains(num)) {
                arrayList.add(num);
            }
        }
       // 使用泛型后，遍历时，就可以指定元素类型 而不是Object
             for (Integer integer:arrayList) {
                 System.out.print(integer+"\t");
             }
             /*for (Object object:arrayList) {
                 System.out.print(object+"\t");
               }*/


            /*Iterator iterator = arrayList.iterator();
            while (iterator.hasNext()) {
                System.out.print(iterator.next()+"\t");
            }*/
    }
}
